package glb;
import static org.junit.Assert.assertTrue;
import robocode.control.events.TurnEndedEvent;
import robocode.control.snapshot.IRobotSnapshot;
import robocode.control.testing.RobotTestBed;
  
  /**
   * Tests that Failbot moves to the top left corner upon the start of a round.
   * @author Gregory Burgess
   *  Based on the test case "TestDaCruzerMovement.java" written by Philip Johnson.
   */  
public class TestInitMove extends RobotTestBed { 
    /** True if the robot visited this corner during the initial turn. */
    boolean visitedUpperLeft = false;
    //track the initial turn
    boolean first = true;
    
    /**
     * Specifies that SittingDuck and Failbot are to be matched up in this test case.
     * @return The comma-delimited list of robots in this match.
     */
    @Override
    public String getRobotNames() {
      return "sample.SittingDuck,glb.Failbot";
    }
    
    /**
     * This test runs for 10 round.
     * @return The number of rounds. 
     */
    @Override
    public int getNumRounds() {
      return 10;
    }
    
    /**
     * Initializes first to true before each round.
     */
    @Override
    public void runSetup() { 
      first = true;
    } 
    
    /**
     * After each turn, check to see if we're at a corner.  If so, set the corresponding flag.
     * @param event Info about the current state of the battle.
     */
    @Override 
    public void onTurnEnded(TurnEndedEvent event) {
      IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
      double xPos = robot.getX();
      double yPos = robot.getY();
      //Checks to see if the robot visited the top left corner
      if ((xPos < 200) && (yPos < 200) && first) {
        visitedUpperLeft = true;
        assertTrue("Check UpperLeft", visitedUpperLeft);
        //check only once per match, at the beginning of the match.
        first = false;
      } 

    } 
    
}


